#!/usr/bin/env bash

if [[ "$XDG_SESSION_TYPE" == "x11" ]];then
    STATUS=$(dunstctl is-paused)
else
    STATUS=$(swaync-client -D)
fi

toggle() {
    if [ $STATUS == "false" ]; then
        if [[ "$XDG_SESSION_TYPE" == "x11" ]];then
            dunstctl set-paused true
        else
            swaync-client -dn
        fi
    else
        if [[ "$XDG_SESSION_TYPE" == "x11" ]];then
            dunstctl set-paused false
        else
            swaync-client -df
        fi
        notify-send --urgency=low -i $HOME/tool/dnd.jpg "Do Not Disturb" "Do not Disturb has been turned off!"
    fi
}

icon() {
    if [ $STATUS == "false" ]; then
        echo "󱑙"
    else
        echo "󰍶"
    fi
}

status() {
    if [ $STATUS == "false" ]; then
        echo "Off"
    else
        echo "On"
    fi
}

if [[ $1 == "--toggle" ]]; then
    toggle
elif [[ $1 == "--icon" ]]; then
    icon
elif [[ $1 == "--status" ]]; then
    status
fi
